package com.sywb.chuangyebao.view;

import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sywb.chuangyebao.R;
import com.sywb.chuangyebao.contract.TutorContract;

import org.bining.footstone.utils.NetUtils;
import org.bining.footstone.widget.PullToRefreshView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 首页-导师
 */
public class TutorActivity extends ActionbarActivity<TutorContract.Presenter> implements TutorContract.View {

    @BindView(R.id.common_recycler)
    RecyclerView commonRecycler;
    @BindView(R.id.common_refresh)
    PullToRefreshView commonRefresh;
    @BindView(R.id.common_nodata_content)
    TextView commonNodataContent;
    @BindView(R.id.common_nodata_icon)
    ImageView commonNodataIcon;
    @BindView(R.id.common_nodata_subtitle)
    TextView commonNodataSubtitle;
    @BindView(R.id.common_nodata)
    RelativeLayout commonNodata;

    @Override
    public int getLayoutId(Bundle bundle) {
        return R.layout.layout_recycler_refresh;
    }

    @Override
    public void initView(Bundle bundle) {
        super.initView(bundle);
        setTitle("导师");
    }

    @Override
    public void initPresenter() {
        mPresenter.initPresenter(this);
    }

    @Override
    public PullToRefreshView getPullToRefreshView() {
        return commonRefresh;
    }

    @Override
    public RecyclerView getRecyclerView() {
        return commonRecycler;
    }

    @Override
    public void setNoData(boolean isNoData) {
        commonNodata.setVisibility(isNoData ? View.VISIBLE : View.GONE);
        if (isNoData) {
            if (!NetUtils.isConnected()) {
                commonNodataIcon.setImageResource(R.drawable.nonetwork);
                commonNodataContent.setText("您的网络不稳定哦，请刷新重试~");
                commonNodataSubtitle.setVisibility(View.VISIBLE);

                commonNodataSubtitle.setText("刷新");
                commonNodataSubtitle.setBackgroundResource(R.drawable.round_pie_theme);
                commonNodataSubtitle.setTextColor(ContextCompat.getColor(mActivity, R.color.colorLight));
                commonNodataSubtitle.setPadding((int) getResources().getDimension(R.dimen.dp_24), (int) getResources().getDimension(R.dimen.dp_6), (int) getResources().getDimension(R.dimen.dp_24), (int) getResources().getDimension(R.dimen.dp_6));
            } else {
                commonNodataIcon.setImageResource(R.drawable.nodata_default);
                commonNodataContent.setText("当前页面没有内容哦~");
                commonNodataSubtitle.setVisibility(View.GONE);
            }
        }
    }
}
